<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - ged.info - test/impl/exception_safety.ipp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">test/impl</a> - exception_safety.ipp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>ged.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2009-06-09</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">170</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">0.0 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">0</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2005-2008.
<span class="lineNum">       2 </span>                : //  Use, modification, and distribution are subject to the
<span class="lineNum">       3 </span>                : //  Boost Software License, Version 1.0. (See accompanying file
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : Facilities to perform exception safety tests
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER
<span class="lineNum">      16 </span>                : #define BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // Boost.Test
<span class="lineNum">      19 </span>                : #include &lt;boost/test/detail/config.hpp&gt;
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span>                : #if BOOST_TEST_SUPPORT_INTERACTION_TESTING
<span class="lineNum">      22 </span>                : 
<span class="lineNum">      23 </span>                : #include &lt;boost/test/detail/global_typedef.hpp&gt;
<span class="lineNum">      24 </span>                : #include &lt;boost/test/detail/unit_test_parameters.hpp&gt;
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : #include &lt;boost/test/utils/callback.hpp&gt;
<span class="lineNum">      27 </span>                : #include &lt;boost/test/utils/wrap_stringstream.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/test/utils/iterator/token_iterator.hpp&gt;
<span class="lineNum">      29 </span>                : 
<span class="lineNum">      30 </span>                : #include &lt;boost/test/interaction_based.hpp&gt;
<span class="lineNum">      31 </span>                : #include &lt;boost/test/test_tools.hpp&gt;
<span class="lineNum">      32 </span>                : #include &lt;boost/test/unit_test_log.hpp&gt;
<span class="lineNum">      33 </span>                : #include &lt;boost/test/framework.hpp&gt;
<span class="lineNum">      34 </span>                : #include &lt;boost/test/test_observer.hpp&gt;
<span class="lineNum">      35 </span>                : #include &lt;boost/test/debug.hpp&gt;
<span class="lineNum">      36 </span>                : 
<span class="lineNum">      37 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">      38 </span>                : 
<span class="lineNum">      39 </span>                : // Boost
<span class="lineNum">      40 </span>                : #include &lt;boost/lexical_cast.hpp&gt;
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span>                : // STL
<span class="lineNum">      43 </span>                : #include &lt;vector&gt;
<span class="lineNum">      44 </span>                : #include &lt;cstdlib&gt;
<span class="lineNum">      45 </span>                : #include &lt;map&gt;
<span class="lineNum">      46 </span>                : #include &lt;iomanip&gt;
<span class="lineNum">      47 </span>                : #include &lt;cctype&gt;
<span class="lineNum">      48 </span>                : #include &lt;boost/limits.hpp&gt;
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span>                : //____________________________________________________________________________//
<span class="lineNum">      51 </span>                : 
<span class="lineNum">      52 </span>                : namespace boost {
<span class="lineNum">      53 </span>                : 
<span class="lineNum">      54 </span>                : using namespace ::boost::unit_test;
<span class="lineNum">      55 </span>                :  
<span class="lineNum">      56 </span>                : namespace itest {
<span class="lineNum">      57 </span>                : 
<span class="lineNum">      58 </span>                : // ************************************************************************** //
<span class="lineNum">      59 </span>                : // **************             execution_path_point             ************** //
<span class="lineNum">      60 </span>                : // ************************************************************************** //
<span class="lineNum">      61 </span>                : 
<span class="lineNum">      62 </span>                : enum exec_path_point_type { EPP_SCOPE, EPP_EXCEPT, EPP_DECISION, EPP_ALLOC };
<span class="lineNum">      63 </span>                : 
<span class="lineNum">      64 </span><span class="lineNoCov">              0 : struct execution_path_point {</span>
<span class="lineNum">      65 </span><span class="lineNoCov">              0 :     execution_path_point( exec_path_point_type t, const_string file, std::size_t line_num )</span>
<span class="lineNum">      66 </span>                :     : m_type( t )
<span class="lineNum">      67 </span>                :     , m_file_name( file )
<span class="lineNum">      68 </span><span class="lineNoCov">              0 :     , m_line_num( line_num )</span>
<span class="lineNum">      69 </span><span class="lineNoCov">              0 :     {}</span>
<span class="lineNum">      70 </span>                : 
<span class="lineNum">      71 </span>                :     exec_path_point_type    m_type;
<span class="lineNum">      72 </span>                :     const_string             m_file_name;
<span class="lineNum">      73 </span>                :     std::size_t             m_line_num;
<span class="lineNum">      74 </span>                : 
<span class="lineNum">      75 </span>                :     // Execution path point specific
<span class="lineNum">      76 </span>                :     struct decision_data {
<span class="lineNum">      77 </span>                :         bool            value;
<span class="lineNum">      78 </span>                :         unsigned        forced_exception_point;
<span class="lineNum">      79 </span>                :     };
<span class="lineNum">      80 </span>                :     struct scope_data {
<span class="lineNum">      81 </span>                :         unsigned        size;
<span class="lineNum">      82 </span>                :         char const*     name;
<span class="lineNum">      83 </span>                :     };
<span class="lineNum">      84 </span>                :     struct except_data {
<span class="lineNum">      85 </span>                :         char const*     description;
<span class="lineNum">      86 </span>                :     };
<span class="lineNum">      87 </span>                :     struct alloc_data {
<span class="lineNum">      88 </span>                :         void*           ptr;
<span class="lineNum">      89 </span>                :         std::size_t     size;
<span class="lineNum">      90 </span>                :     };
<span class="lineNum">      91 </span>                : 
<span class="lineNum">      92 </span>                :     union {
<span class="lineNum">      93 </span>                :         struct decision_data    m_decision;
<span class="lineNum">      94 </span>                :         struct scope_data       m_scope;
<span class="lineNum">      95 </span>                :         struct except_data      m_except;
<span class="lineNum">      96 </span>                :         struct alloc_data       m_alloc;
<span class="lineNum">      97 </span>                :     };
<span class="lineNum">      98 </span>                : };
<span class="lineNum">      99 </span>                : 
<span class="lineNum">     100 </span>                : // ************************************************************************** //
<span class="lineNum">     101 </span>                : // **************     exception safety test implementation     ************** //
<span class="lineNum">     102 </span>                : // ************************************************************************** //
<span class="lineNum">     103 </span>                : 
<span class="lineNum">     104 </span>                : struct exception_safety_tester : itest::manager, test_observer {
<span class="lineNum">     105 </span>                :     // helpers types
<span class="lineNum">     106 </span>                :     struct unique_exception {};
<span class="lineNum">     107 </span>                : 
<span class="lineNum">     108 </span>                :     // Constructor
<span class="lineNum">     109 </span>                :     explicit            exception_safety_tester( const_string test_name );
<span class="lineNum">     110 </span>                :     ~exception_safety_tester();
<span class="lineNum">     111 </span>                : 
<span class="lineNum">     112 </span>                :     // check last run and prepare for next
<span class="lineNum">     113 </span>                :     bool                next_execution_path();
<span class="lineNum">     114 </span>                : 
<span class="lineNum">     115 </span>                :     // memory tracking
<span class="lineNum">     116 </span>                : 
<span class="lineNum">     117 </span>                :     // manager interface implementation
<span class="lineNum">     118 </span>                :     virtual void        exception_point( const_string file, std::size_t line_num, const_string description );
<span class="lineNum">     119 </span>                :     virtual bool        decision_point( const_string file, std::size_t line_num );
<span class="lineNum">     120 </span>                :     virtual unsigned    enter_scope( const_string file, std::size_t line_num, const_string scope_name );
<span class="lineNum">     121 </span>                :     virtual void        leave_scope( unsigned enter_scope_point );
<span class="lineNum">     122 </span>                :     virtual void        allocated( const_string file, std::size_t line_num, void* p, std::size_t s );
<span class="lineNum">     123 </span>                :     virtual void        freed( void* p );
<span class="lineNum">     124 </span>                : 
<span class="lineNum">     125 </span>                :     // test observer interface
<span class="lineNum">     126 </span>                :     virtual void        assertion_result( bool passed );
<span class="lineNum">     127 </span><span class="lineNoCov">              0 :     virtual int         priority() { return (std::numeric_limits&lt;int&gt;::max)(); } // we want this observer to run the last</span>
<span class="lineNum">     128 </span>                : 
<span class="lineNum">     129 </span>                : private:
<span class="lineNum">     130 </span>                :     void                failure_point();
<span class="lineNum">     131 </span>                :     void                report_error();
<span class="lineNum">     132 </span>                : 
<span class="lineNum">     133 </span>                :     typedef std::vector&lt;execution_path_point&gt;   exec_path;
<span class="lineNum">     134 </span>                :     typedef std::map&lt;void*,unsigned&gt;            registry;
<span class="lineNum">     135 </span>                : 
<span class="lineNum">     136 </span>                :     // Data members
<span class="lineNum">     137 </span>                :     bool        m_internal_activity;
<span class="lineNum">     138 </span>                :     
<span class="lineNum">     139 </span>                :     unsigned    m_exception_point_counter;
<span class="lineNum">     140 </span>                :     unsigned    m_forced_exception_point;
<span class="lineNum">     141 </span>                : 
<span class="lineNum">     142 </span>                :     unsigned    m_exec_path_point;
<span class="lineNum">     143 </span>                :     exec_path   m_execution_path;
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span>                :     unsigned    m_exec_path_counter;
<span class="lineNum">     146 </span>                :     unsigned    m_break_exec_path;
<span class="lineNum">     147 </span>                :     
<span class="lineNum">     148 </span>                :     bool        m_invairant_failed;
<span class="lineNum">     149 </span>                :     registry    m_memory_in_use;
<span class="lineNum">     150 </span>                : };
<span class="lineNum">     151 </span>                : 
<span class="lineNum">     152 </span>                : //____________________________________________________________________________//
<span class="lineNum">     153 </span>                : 
<span class="lineNum">     154 </span>                : struct activity_guard {
<span class="lineNum">     155 </span>                :     bool&amp; m_v;
<span class="lineNum">     156 </span>                : 
<span class="lineNum">     157 </span><span class="lineNoCov">              0 :     activity_guard( bool&amp; v ) : m_v( v )    { m_v = true; }</span>
<span class="lineNum">     158 </span><span class="lineNoCov">              0 :     ~activity_guard()                       { m_v = false; }</span>
<span class="lineNum">     159 </span>                : };
<span class="lineNum">     160 </span>                : 
<span class="lineNum">     161 </span>                : //____________________________________________________________________________//
<span class="lineNum">     162 </span>                : 
<span class="lineNum">     163 </span><span class="lineNoCov">              0 : exception_safety_tester::exception_safety_tester( const_string test_name )</span>
<span class="lineNum">     164 </span>                : : m_internal_activity( true )
<span class="lineNum">     165 </span>                : , m_exception_point_counter( 0 )
<span class="lineNum">     166 </span>                : , m_forced_exception_point( 1 )
<span class="lineNum">     167 </span>                : , m_exec_path_point( 0 )
<span class="lineNum">     168 </span>                : , m_exec_path_counter( 1 )
<span class="lineNum">     169 </span>                : , m_break_exec_path( (unsigned)-1 )
<span class="lineNum">     170 </span><span class="lineNoCov">              0 : , m_invairant_failed( false )</span>
<span class="lineNum">     171 </span>                : {
<span class="lineNum">     172 </span><span class="lineNoCov">              0 :     framework::register_observer( *this );</span>
<span class="lineNum">     173 </span>                : 
<span class="lineNum">     174 </span><span class="lineNoCov">              0 :     if( !runtime_config::break_exec_path().is_empty() ) {</span>
<span class="lineNum">     175 </span>                :         using namespace unit_test;
<span class="lineNum">     176 </span>                :         
<span class="lineNum">     177 </span>                :         string_token_iterator tit( runtime_config::break_exec_path(), 
<span class="lineNum">     178 </span><span class="lineNoCov">              0 :                                    (dropped_delimeters = &quot;:&quot;,kept_delimeters = &quot; &quot;) );</span>
<span class="lineNum">     179 </span>                :         
<span class="lineNum">     180 </span><span class="lineNoCov">              0 :         const_string test_to_break = *tit;</span>
<span class="lineNum">     181 </span>                :         
<span class="lineNum">     182 </span><span class="lineNoCov">              0 :         if( test_to_break == test_name ) {</span>
<span class="lineNum">     183 </span><span class="lineNoCov">              0 :             ++tit;</span>
<span class="lineNum">     184 </span>                :             
<span class="lineNum">     185 </span><span class="lineNoCov">              0 :             m_break_exec_path = lexical_cast&lt;unsigned&gt;( *tit );</span>
<span class="lineNum">     186 </span>                :         }
<span class="lineNum">     187 </span>                :     }
<span class="lineNum">     188 </span>                :     
<span class="lineNum">     189 </span><span class="lineNoCov">              0 :     m_internal_activity = false;</span>
<span class="lineNum">     190 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     191 </span>                : 
<span class="lineNum">     192 </span>                : //____________________________________________________________________________//
<span class="lineNum">     193 </span>                : 
<span class="lineNum">     194 </span><span class="lineNoCov">              0 : exception_safety_tester::~exception_safety_tester()</span>
<span class="lineNum">     195 </span>                : {
<span class="lineNum">     196 </span><span class="lineNoCov">              0 :     m_internal_activity = true;</span>
<span class="lineNum">     197 </span>                :     
<span class="lineNum">     198 </span><span class="lineNoCov">              0 :     framework::deregister_observer( *this );</span>
<span class="lineNum">     199 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     200 </span>                : 
<span class="lineNum">     201 </span>                : //____________________________________________________________________________//
<span class="lineNum">     202 </span>                : 
<span class="lineNum">     203 </span>                : bool
<span class="lineNum">     204 </span><span class="lineNoCov">              0 : exception_safety_tester::next_execution_path()</span>
<span class="lineNum">     205 </span>                : {
<span class="lineNum">     206 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     207 </span>                : 
<span class="lineNum">     208 </span>                :     // check memory usage
<span class="lineNum">     209 </span><span class="lineNoCov">              0 :     if( m_execution_path.size() &gt; 0 ) {</span>
<span class="lineNum">     210 </span><span class="lineNoCov">              0 :         bool errors_detected = m_invairant_failed || (m_memory_in_use.size() != 0);</span>
<span class="lineNum">     211 </span><span class="lineNoCov">              0 :         framework::assertion_result( !errors_detected );</span>
<span class="lineNum">     212 </span>                : 
<span class="lineNum">     213 </span><span class="lineNoCov">              0 :         if( errors_detected )</span>
<span class="lineNum">     214 </span><span class="lineNoCov">              0 :             report_error();</span>
<span class="lineNum">     215 </span>                : 
<span class="lineNum">     216 </span><span class="lineNoCov">              0 :         m_memory_in_use.clear();</span>
<span class="lineNum">     217 </span>                :     }
<span class="lineNum">     218 </span>                : 
<span class="lineNum">     219 </span><span class="lineNoCov">              0 :     m_exec_path_point           = 0;</span>
<span class="lineNum">     220 </span><span class="lineNoCov">              0 :     m_exception_point_counter   = 0;</span>
<span class="lineNum">     221 </span><span class="lineNoCov">              0 :     m_invairant_failed          = false;</span>
<span class="lineNum">     222 </span><span class="lineNoCov">              0 :     ++m_exec_path_counter;</span>
<span class="lineNum">     223 </span>                : 
<span class="lineNum">     224 </span><span class="lineNoCov">              0 :     while( m_execution_path.size() &gt; 0 ) {</span>
<span class="lineNum">     225 </span><span class="lineNoCov">              0 :         switch( m_execution_path.back().m_type ) {</span>
<span class="lineNum">     226 </span>                :         case EPP_SCOPE:
<span class="lineNum">     227 </span>                :         case EPP_ALLOC:
<span class="lineNum">     228 </span><span class="lineNoCov">              0 :             m_execution_path.pop_back();</span>
<span class="lineNum">     229 </span><span class="lineNoCov">              0 :             break;</span>
<span class="lineNum">     230 </span>                : 
<span class="lineNum">     231 </span>                :         case EPP_DECISION:
<span class="lineNum">     232 </span><span class="lineNoCov">              0 :             if( !m_execution_path.back().m_decision.value ) {</span>
<span class="lineNum">     233 </span><span class="lineNoCov">              0 :                 m_execution_path.pop_back();</span>
<span class="lineNum">     234 </span><span class="lineNoCov">              0 :                 break;</span>
<span class="lineNum">     235 </span>                :             }
<span class="lineNum">     236 </span>                : 
<span class="lineNum">     237 </span><span class="lineNoCov">              0 :             m_execution_path.back().m_decision.value = false;</span>
<span class="lineNum">     238 </span><span class="lineNoCov">              0 :             m_forced_exception_point = m_execution_path.back().m_decision.forced_exception_point;</span>
<span class="lineNum">     239 </span><span class="lineNoCov">              0 :             return true;</span>
<span class="lineNum">     240 </span>                : 
<span class="lineNum">     241 </span>                :         case EPP_EXCEPT:
<span class="lineNum">     242 </span><span class="lineNoCov">              0 :             m_execution_path.pop_back();</span>
<span class="lineNum">     243 </span><span class="lineNoCov">              0 :             ++m_forced_exception_point;</span>
<span class="lineNum">     244 </span><span class="lineNoCov">              0 :             return true;</span>
<span class="lineNum">     245 </span>                :         }
<span class="lineNum">     246 </span>                :     }
<span class="lineNum">     247 </span>                : 
<span class="lineNum">     248 </span><span class="lineNoCov">              0 :     BOOST_TEST_MESSAGE( &quot;Total tested &quot; &lt;&lt; --m_exec_path_counter &lt;&lt; &quot; execution path&quot; );</span>
<span class="lineNum">     249 </span>                : 
<span class="lineNum">     250 </span><span class="lineNoCov">              0 :     return false;</span>
<span class="lineNum">     251 </span>                : }
<span class="lineNum">     252 </span>                : 
<span class="lineNum">     253 </span>                : //____________________________________________________________________________//
<span class="lineNum">     254 </span>                : 
<span class="lineNum">     255 </span>                : void
<span class="lineNum">     256 </span><span class="lineNoCov">              0 : exception_safety_tester::exception_point( const_string file, std::size_t line_num, const_string description )</span>
<span class="lineNum">     257 </span>                : {
<span class="lineNum">     258 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     259 </span>                : 
<span class="lineNum">     260 </span><span class="lineNoCov">              0 :     if( ++m_exception_point_counter == m_forced_exception_point ) {</span>
<span class="lineNum">     261 </span>                :         m_execution_path.push_back(
<span class="lineNum">     262 </span><span class="lineNoCov">              0 :             execution_path_point( EPP_EXCEPT, file, line_num ) );</span>
<span class="lineNum">     263 </span>                : 
<span class="lineNum">     264 </span><span class="lineNoCov">              0 :         m_execution_path.back().m_except.description = description.begin();</span>
<span class="lineNum">     265 </span>                : 
<span class="lineNum">     266 </span><span class="lineNoCov">              0 :         ++m_exec_path_point;</span>
<span class="lineNum">     267 </span>                : 
<span class="lineNum">     268 </span><span class="lineNoCov">              0 :         failure_point();</span>
<span class="lineNum">     269 </span><span class="lineNoCov">              0 :     }</span>
<span class="lineNum">     270 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     271 </span>                : 
<span class="lineNum">     272 </span>                : //____________________________________________________________________________//
<span class="lineNum">     273 </span>                : 
<span class="lineNum">     274 </span>                : bool
<span class="lineNum">     275 </span><span class="lineNoCov">              0 : exception_safety_tester::decision_point( const_string file, std::size_t line_num )</span>
<span class="lineNum">     276 </span>                : {
<span class="lineNum">     277 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     278 </span>                : 
<span class="lineNum">     279 </span><span class="lineNoCov">              0 :     if( m_exec_path_point &lt; m_execution_path.size() ) {</span>
<span class="lineNum">     280 </span><span class="lineNoCov">              0 :         BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_DECISION &amp;&amp;</span>
<span class="lineNum">     281 </span>                :                                m_execution_path[m_exec_path_point].m_file_name == file &amp;&amp;
<span class="lineNum">     282 </span>                :                                m_execution_path[m_exec_path_point].m_line_num == line_num,
<span class="lineNum">     283 </span>                :                                &quot;Function under test exibit non-deterministic behavior&quot; );
<span class="lineNum">     284 </span>                :     }
<span class="lineNum">     285 </span>                :     else {
<span class="lineNum">     286 </span>                :         m_execution_path.push_back(
<span class="lineNum">     287 </span><span class="lineNoCov">              0 :             execution_path_point( EPP_DECISION, file, line_num ) );</span>
<span class="lineNum">     288 </span>                : 
<span class="lineNum">     289 </span><span class="lineNoCov">              0 :         m_execution_path.back().m_decision.value = true;</span>
<span class="lineNum">     290 </span><span class="lineNoCov">              0 :         m_execution_path.back().m_decision.forced_exception_point = m_forced_exception_point;</span>
<span class="lineNum">     291 </span>                :     }
<span class="lineNum">     292 </span>                : 
<span class="lineNum">     293 </span><span class="lineNoCov">              0 :     return m_execution_path[m_exec_path_point++].m_decision.value;</span>
<span class="lineNum">     294 </span>                : }
<span class="lineNum">     295 </span>                : 
<span class="lineNum">     296 </span>                : //____________________________________________________________________________//
<span class="lineNum">     297 </span>                : 
<span class="lineNum">     298 </span>                : unsigned
<span class="lineNum">     299 </span><span class="lineNoCov">              0 : exception_safety_tester::enter_scope( const_string file, std::size_t line_num, const_string scope_name )</span>
<span class="lineNum">     300 </span>                : {
<span class="lineNum">     301 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     302 </span>                : 
<span class="lineNum">     303 </span><span class="lineNoCov">              0 :     if( m_exec_path_point &lt; m_execution_path.size() ) {</span>
<span class="lineNum">     304 </span><span class="lineNoCov">              0 :         BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_SCOPE &amp;&amp;</span>
<span class="lineNum">     305 </span>                :                                m_execution_path[m_exec_path_point].m_file_name == file &amp;&amp;
<span class="lineNum">     306 </span>                :                                m_execution_path[m_exec_path_point].m_line_num == line_num,
<span class="lineNum">     307 </span>                :                                &quot;Function under test exibit non-deterministic behavior&quot; );
<span class="lineNum">     308 </span>                :     }
<span class="lineNum">     309 </span>                :     else {
<span class="lineNum">     310 </span>                :         m_execution_path.push_back(
<span class="lineNum">     311 </span><span class="lineNoCov">              0 :             execution_path_point( EPP_SCOPE, file, line_num ) );</span>
<span class="lineNum">     312 </span>                :     }
<span class="lineNum">     313 </span>                : 
<span class="lineNum">     314 </span><span class="lineNoCov">              0 :     m_execution_path[m_exec_path_point].m_scope.size = 0;</span>
<span class="lineNum">     315 </span><span class="lineNoCov">              0 :     m_execution_path[m_exec_path_point].m_scope.name = scope_name.begin();</span>
<span class="lineNum">     316 </span>                : 
<span class="lineNum">     317 </span><span class="lineNoCov">              0 :     return m_exec_path_point++;</span>
<span class="lineNum">     318 </span>                : }
<span class="lineNum">     319 </span>                : 
<span class="lineNum">     320 </span>                : //____________________________________________________________________________//
<span class="lineNum">     321 </span>                : 
<span class="lineNum">     322 </span>                : void
<span class="lineNum">     323 </span><span class="lineNoCov">              0 : exception_safety_tester::leave_scope( unsigned enter_scope_point )</span>
<span class="lineNum">     324 </span>                : {
<span class="lineNum">     325 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     326 </span>                : 
<span class="lineNum">     327 </span><span class="lineNoCov">              0 :     BOOST_REQUIRE_MESSAGE( m_execution_path[enter_scope_point].m_type == EPP_SCOPE,</span>
<span class="lineNum">     328 </span>                :                            &quot;Function under test exibit non-deterministic behavior&quot; );
<span class="lineNum">     329 </span>                : 
<span class="lineNum">     330 </span><span class="lineNoCov">              0 :     m_execution_path[enter_scope_point].m_scope.size = m_exec_path_point - enter_scope_point;</span>
<span class="lineNum">     331 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     332 </span>                : 
<span class="lineNum">     333 </span>                : //____________________________________________________________________________//
<span class="lineNum">     334 </span>                : 
<span class="lineNum">     335 </span>                : void
<span class="lineNum">     336 </span><span class="lineNoCov">              0 : exception_safety_tester::allocated( const_string file, std::size_t line_num, void* p, std::size_t s )</span>
<span class="lineNum">     337 </span>                : {
<span class="lineNum">     338 </span><span class="lineNoCov">              0 :     if( m_internal_activity )</span>
<span class="lineNum">     339 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     340 </span>                : 
<span class="lineNum">     341 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     342 </span>                : 
<span class="lineNum">     343 </span><span class="lineNoCov">              0 :     if( m_exec_path_point &lt; m_execution_path.size() )</span>
<span class="lineNum">     344 </span><span class="lineNoCov">              0 :         BOOST_REQUIRE_MESSAGE( m_execution_path[m_exec_path_point].m_type == EPP_ALLOC,</span>
<span class="lineNum">     345 </span>                :                                &quot;Function under test exibit non-deterministic behavior&quot; );
<span class="lineNum">     346 </span>                :     else
<span class="lineNum">     347 </span>                :         m_execution_path.push_back(
<span class="lineNum">     348 </span><span class="lineNoCov">              0 :             execution_path_point( EPP_ALLOC, file, line_num ) );</span>
<span class="lineNum">     349 </span>                : 
<span class="lineNum">     350 </span><span class="lineNoCov">              0 :     m_execution_path[m_exec_path_point].m_alloc.ptr  = p;</span>
<span class="lineNum">     351 </span><span class="lineNoCov">              0 :     m_execution_path[m_exec_path_point].m_alloc.size = s;</span>
<span class="lineNum">     352 </span>                : 
<span class="lineNum">     353 </span><span class="lineNoCov">              0 :     m_memory_in_use.insert( std::make_pair( p, m_exec_path_point++ ) );</span>
<span class="lineNum">     354 </span>                : }
<span class="lineNum">     355 </span>                : 
<span class="lineNum">     356 </span>                : //____________________________________________________________________________//
<span class="lineNum">     357 </span>                : 
<span class="lineNum">     358 </span>                : void
<span class="lineNum">     359 </span><span class="lineNoCov">              0 : exception_safety_tester::freed( void* p )</span>
<span class="lineNum">     360 </span>                : {
<span class="lineNum">     361 </span><span class="lineNoCov">              0 :     if( m_internal_activity )</span>
<span class="lineNum">     362 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     363 </span>                : 
<span class="lineNum">     364 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     365 </span>                : 
<span class="lineNum">     366 </span><span class="lineNoCov">              0 :     registry::iterator it = m_memory_in_use.find( p );</span>
<span class="lineNum">     367 </span><span class="lineNoCov">              0 :     if( it != m_memory_in_use.end() ) {</span>
<span class="lineNum">     368 </span><span class="lineNoCov">              0 :         m_execution_path[it-&gt;second].m_alloc.ptr = 0;</span>
<span class="lineNum">     369 </span><span class="lineNoCov">              0 :         m_memory_in_use.erase( it );</span>
<span class="lineNum">     370 </span><span class="lineNoCov">              0 :     }</span>
<span class="lineNum">     371 </span>                : }
<span class="lineNum">     372 </span>                : 
<span class="lineNum">     373 </span>                : //____________________________________________________________________________//
<span class="lineNum">     374 </span>                : 
<span class="lineNum">     375 </span>                : void
<span class="lineNum">     376 </span><span class="lineNoCov">              0 : exception_safety_tester::assertion_result( bool passed )</span>
<span class="lineNum">     377 </span>                : {
<span class="lineNum">     378 </span><span class="lineNoCov">              0 :     if( !m_internal_activity &amp;&amp; !passed ) {</span>
<span class="lineNum">     379 </span><span class="lineNoCov">              0 :         m_invairant_failed = true;</span>
<span class="lineNum">     380 </span>                : 
<span class="lineNum">     381 </span><span class="lineNoCov">              0 :         failure_point();</span>
<span class="lineNum">     382 </span>                :     }
<span class="lineNum">     383 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     384 </span>                : 
<span class="lineNum">     385 </span>                : //____________________________________________________________________________//
<span class="lineNum">     386 </span>                : 
<span class="lineNum">     387 </span>                : void
<span class="lineNum">     388 </span><span class="lineNoCov">              0 : exception_safety_tester::failure_point()</span>
<span class="lineNum">     389 </span>                : {
<span class="lineNum">     390 </span><span class="lineNoCov">              0 :     if( m_exec_path_counter == m_break_exec_path )</span>
<span class="lineNum">     391 </span><span class="lineNoCov">              0 :         debug::debugger_break();</span>
<span class="lineNum">     392 </span>                :     
<span class="lineNum">     393 </span><span class="lineNoCov">              0 :     throw unique_exception();</span>
<span class="lineNum">     394 </span>                : }
<span class="lineNum">     395 </span>                : 
<span class="lineNum">     396 </span>                : //____________________________________________________________________________//
<span class="lineNum">     397 </span>                :     
<span class="lineNum">     398 </span>                : namespace {
<span class="lineNum">     399 </span>                : 
<span class="lineNum">     400 </span>                : inline void
<span class="lineNum">     401 </span><span class="lineNoCov">              0 : format_location( wrap_stringstream&amp; formatter, execution_path_point const&amp; /*p*/, unsigned indent )</span>
<span class="lineNum">     402 </span>                : {
<span class="lineNum">     403 </span><span class="lineNoCov">              0 :     if( indent )</span>
<span class="lineNum">     404 </span><span class="lineNoCov">              0 :         formatter &lt;&lt; std::left &lt;&lt; std::setw( indent ) &lt;&lt; &quot;&quot;;</span>
<span class="lineNum">     405 </span>                : 
<span class="lineNum">     406 </span>                : // !! ?? optional   if( p.m_file_name )
<span class="lineNum">     407 </span>                : //        formatter &lt;&lt; p.m_file_name &lt;&lt; '(' &lt;&lt; p.m_line_num &lt;&lt; &quot;): &quot;;
<span class="lineNum">     408 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     409 </span>                : 
<span class="lineNum">     410 </span>                : //____________________________________________________________________________//
<span class="lineNum">     411 </span>                : 
<span class="lineNum">     412 </span>                : template&lt;typename ExecPathIt&gt;
<span class="lineNum">     413 </span>                : inline void
<span class="lineNum">     414 </span><span class="lineNoCov">              0 : format_execution_path( wrap_stringstream&amp; formatter, ExecPathIt it, ExecPathIt end, unsigned indent = 0 )</span>
<span class="lineNum">     415 </span>                : {
<span class="lineNum">     416 </span><span class="lineNoCov">              0 :     while( it != end ) {</span>
<span class="lineNum">     417 </span><span class="lineNoCov">              0 :         switch( it-&gt;m_type ) {</span>
<span class="lineNum">     418 </span>                :         case EPP_SCOPE:
<span class="lineNum">     419 </span><span class="lineNoCov">              0 :             format_location( formatter, *it, indent );</span>
<span class="lineNum">     420 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; &quot;&gt; \&quot;&quot; &lt;&lt; it-&gt;m_scope.name &lt;&lt; &quot;\&quot;\n&quot;;</span>
<span class="lineNum">     421 </span><span class="lineNoCov">              0 :             format_execution_path( formatter, it+1, it + it-&gt;m_scope.size, indent + 2 );</span>
<span class="lineNum">     422 </span><span class="lineNoCov">              0 :             format_location( formatter, *it, indent );</span>
<span class="lineNum">     423 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; &quot;&lt; \&quot;&quot; &lt;&lt; it-&gt;m_scope.name &lt;&lt; &quot;\&quot;\n&quot;;</span>
<span class="lineNum">     424 </span><span class="lineNoCov">              0 :             it += it-&gt;m_scope.size;</span>
<span class="lineNum">     425 </span><span class="lineNoCov">              0 :             break;</span>
<span class="lineNum">     426 </span>                : 
<span class="lineNum">     427 </span>                :         case EPP_DECISION:
<span class="lineNum">     428 </span><span class="lineNoCov">              0 :             format_location( formatter, *it, indent );</span>
<span class="lineNum">     429 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; &quot;Decision made as &quot; &lt;&lt; std::boolalpha &lt;&lt; it-&gt;m_decision.value &lt;&lt; '\n';</span>
<span class="lineNum">     430 </span><span class="lineNoCov">              0 :             ++it;</span>
<span class="lineNum">     431 </span><span class="lineNoCov">              0 :             break;</span>
<span class="lineNum">     432 </span>                : 
<span class="lineNum">     433 </span>                :         case EPP_EXCEPT:
<span class="lineNum">     434 </span><span class="lineNoCov">              0 :             format_location( formatter, *it, indent );</span>
<span class="lineNum">     435 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; &quot;Forced failure&quot;;</span>
<span class="lineNum">     436 </span><span class="lineNoCov">              0 :             if( it-&gt;m_except.description )</span>
<span class="lineNum">     437 </span><span class="lineNoCov">              0 :                 formatter &lt;&lt; &quot;: &quot; &lt;&lt; it-&gt;m_except.description;</span>
<span class="lineNum">     438 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; &quot;\n&quot;;</span>
<span class="lineNum">     439 </span><span class="lineNoCov">              0 :             ++it;</span>
<span class="lineNum">     440 </span><span class="lineNoCov">              0 :             break;</span>
<span class="lineNum">     441 </span>                : 
<span class="lineNum">     442 </span>                :         case EPP_ALLOC:
<span class="lineNum">     443 </span><span class="lineNoCov">              0 :             if( it-&gt;m_alloc.ptr ) {</span>
<span class="lineNum">     444 </span><span class="lineNoCov">              0 :                 format_location( formatter, *it, indent );</span>
<span class="lineNum">     445 </span><span class="lineNoCov">              0 :                 formatter &lt;&lt; &quot;Allocated memory block 0x&quot; &lt;&lt; std::uppercase &lt;&lt; it-&gt;m_alloc.ptr </span>
<span class="lineNum">     446 </span>                :                           &lt;&lt; &quot;, &quot; &lt;&lt; it-&gt;m_alloc.size &lt;&lt; &quot; bytes long: &lt;&quot;;
<span class="lineNum">     447 </span>                : 
<span class="lineNum">     448 </span>                :                 unsigned i;
<span class="lineNum">     449 </span><span class="lineNoCov">              0 :                 for( i = 0; i &lt; std::min&lt;std::size_t&gt;( it-&gt;m_alloc.size, 8 ); i++ ) {</span>
<span class="lineNum">     450 </span><span class="lineNoCov">              0 :                     unsigned char c = ((unsigned char*)it-&gt;m_alloc.ptr)[i];</span>
<span class="lineNum">     451 </span><span class="lineNoCov">              0 :                     if( (std::isprint)( c ) )</span>
<span class="lineNum">     452 </span><span class="lineNoCov">              0 :                         formatter &lt;&lt; c;</span>
<span class="lineNum">     453 </span>                :                     else
<span class="lineNum">     454 </span><span class="lineNoCov">              0 :                         formatter &lt;&lt; '.';</span>
<span class="lineNum">     455 </span>                :                 }
<span class="lineNum">     456 </span>                : 
<span class="lineNum">     457 </span><span class="lineNoCov">              0 :                 formatter &lt;&lt; &quot;&gt; &quot;;</span>
<span class="lineNum">     458 </span>                : 
<span class="lineNum">     459 </span><span class="lineNoCov">              0 :                 for( i = 0; i &lt; std::min&lt;std::size_t&gt;( it-&gt;m_alloc.size, 8 ); i++ ) {</span>
<span class="lineNum">     460 </span><span class="lineNoCov">              0 :                     unsigned c = ((unsigned char*)it-&gt;m_alloc.ptr)[i];</span>
<span class="lineNum">     461 </span><span class="lineNoCov">              0 :                     formatter &lt;&lt; std::hex &lt;&lt; std::uppercase &lt;&lt; c &lt;&lt; ' ';</span>
<span class="lineNum">     462 </span>                :                 }
<span class="lineNum">     463 </span>                : 
<span class="lineNum">     464 </span><span class="lineNoCov">              0 :                 formatter &lt;&lt; &quot;\n&quot;;</span>
<span class="lineNum">     465 </span>                :             }
<span class="lineNum">     466 </span><span class="lineNoCov">              0 :             ++it;</span>
<span class="lineNum">     467 </span>                :             break;
<span class="lineNum">     468 </span>                :         }
<span class="lineNum">     469 </span>                :     }
<span class="lineNum">     470 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     471 </span>                : 
<span class="lineNum">     472 </span>                : //____________________________________________________________________________//
<span class="lineNum">     473 </span>                : 
<span class="lineNum">     474 </span>                : } // local namespace
<span class="lineNum">     475 </span>                : 
<span class="lineNum">     476 </span>                : void
<span class="lineNum">     477 </span><span class="lineNoCov">              0 : exception_safety_tester::report_error()</span>
<span class="lineNum">     478 </span>                : {
<span class="lineNum">     479 </span><span class="lineNoCov">              0 :     activity_guard ag( m_internal_activity );</span>
<span class="lineNum">     480 </span>                : 
<span class="lineNum">     481 </span>                :     unit_test_log &lt;&lt; unit_test::log::begin( m_execution_path.back().m_file_name,
<span class="lineNum">     482 </span>                :                                             m_execution_path.back().m_line_num )
<span class="lineNum">     483 </span><span class="lineNoCov">              0 :                   &lt;&lt; log_all_errors;</span>
<span class="lineNum">     484 </span>                : 
<span class="lineNum">     485 </span><span class="lineNoCov">              0 :     wrap_stringstream formatter;</span>
<span class="lineNum">     486 </span>                : 
<span class="lineNum">     487 </span><span class="lineNoCov">              0 :     if( m_invairant_failed )</span>
<span class="lineNum">     488 </span><span class="lineNoCov">              0 :         formatter &lt;&lt; &quot;Failed invariant&quot;;</span>
<span class="lineNum">     489 </span>                : 
<span class="lineNum">     490 </span><span class="lineNoCov">              0 :     if( m_memory_in_use.size() != 0 ) {</span>
<span class="lineNum">     491 </span><span class="lineNoCov">              0 :         if( m_invairant_failed )</span>
<span class="lineNum">     492 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; &quot; and &quot;;</span>
<span class="lineNum">     493 </span>                : 
<span class="lineNum">     494 </span><span class="lineNoCov">              0 :         formatter &lt;&lt; (unsigned int)m_memory_in_use.size() &lt;&lt; &quot; memory leak&quot;;</span>
<span class="lineNum">     495 </span><span class="lineNoCov">              0 :         if( m_memory_in_use.size() &gt; 1 )</span>
<span class="lineNum">     496 </span><span class="lineNoCov">              0 :             formatter &lt;&lt; 's';</span>
<span class="lineNum">     497 </span>                :     }
<span class="lineNum">     498 </span><span class="lineNoCov">              0 :     formatter &lt;&lt; &quot; detected in the execution path &quot; &lt;&lt; m_exec_path_counter &lt;&lt; &quot;:\n&quot;;</span>
<span class="lineNum">     499 </span>                : 
<span class="lineNum">     500 </span><span class="lineNoCov">              0 :     format_execution_path( formatter, m_execution_path.begin(), m_execution_path.end() );</span>
<span class="lineNum">     501 </span>                : 
<span class="lineNum">     502 </span><span class="lineNoCov">              0 :     unit_test_log &lt;&lt; const_string( formatter.str() ) &lt;&lt; unit_test::log::end();</span>
<span class="lineNum">     503 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     504 </span>                : 
<span class="lineNum">     505 </span>                : //____________________________________________________________________________//
<span class="lineNum">     506 </span>                : 
<span class="lineNum">     507 </span>                : // ************************************************************************** //
<span class="lineNum">     508 </span>                : // **************             exception safety test            ************** //
<span class="lineNum">     509 </span>                : // ************************************************************************** //
<span class="lineNum">     510 </span>                : 
<span class="lineNum">     511 </span>                : void BOOST_TEST_DECL
<span class="lineNum">     512 </span><span class="lineNoCov">              0 : exception_safety( callback0&lt;&gt; const&amp; F, const_string test_name )</span>
<span class="lineNum">     513 </span>                : {
<span class="lineNum">     514 </span><span class="lineNoCov">              0 :     exception_safety_tester est( test_name );</span>
<span class="lineNum">     515 </span>                : 
<span class="lineNum">     516 </span><span class="lineNoCov">              0 :     do {</span>
<span class="lineNum">     517 </span>                :         try {
<span class="lineNum">     518 </span><span class="lineNoCov">              0 :             F();</span>
<span class="lineNum">     519 </span>                :         }
<span class="lineNum">     520 </span><span class="lineNoCov">              0 :         catch( exception_safety_tester::unique_exception const&amp; ) {}</span>
<span class="lineNum">     521 </span>                : 
<span class="lineNum">     522 </span><span class="lineNoCov">              0 :     } while( est.next_execution_path() );</span>
<span class="lineNum">     523 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     524 </span>                : 
<span class="lineNum">     525 </span>                : //____________________________________________________________________________//
<span class="lineNum">     526 </span>                : 
<span class="lineNum">     527 </span>                : }  // namespace itest
<span class="lineNum">     528 </span>                : 
<span class="lineNum">     529 </span>                : } // namespace boost
<span class="lineNum">     530 </span>                : 
<span class="lineNum">     531 </span>                : //____________________________________________________________________________//
<span class="lineNum">     532 </span>                : 
<span class="lineNum">     533 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     534 </span>                : 
<span class="lineNum">     535 </span>                : #endif // non-ancient compiler
<span class="lineNum">     536 </span>                : 
<span class="lineNum">     537 </span>                : #endif // BOOST_TEST_EXECUTION_SAFETY_IPP_112005GER
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
